<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title><?= $sysName ?></title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        table {
            text-align: center;
            border-collapse: collapse
        }

        .fileMes {
            width: 800px;
            height: auto;
            margin: 0 auto;
            background: #fff;
        }

        .fileMes table tr {
            height: 30px;
        }

        .fileMes table tr td {
            border: 1px #abcdef solid;
            padding: 10px;
        }

        .updata {
            width: 800px;
            height: auto;
            margin: 0 auto;
            background: #fff;
        }

        .updata textarea {
            width: 100%;
            height: 300px;
            text-align: left;
        }

        .btn {
            width: 100px;
            height: 30px;
            background: #a0c0ef;
            color: white;
            border: 0px;
            color: #333;
        }

        .btn:hover {
            background: #abcdef;
        }

        .createFile {
            height: auto;
            margin: 0 auto;
            margin-bottom: 20px;
            margin-left: 400px;
        }

        pre {
            white-space: pre-wrap; /*css-3*/
            white-space: -moz-pre-wrap; /*Mozilla,since1999*/
            white-space: -pre-wrap; /*Opera4-6*/
            white-space: -o-pre-wrap; /*Opera7*/
            word-wrap: break-word; /*InternetExplorer5.5+*/
        }
    </style>
    <script type="text/javascript">
        function backIndex() {
            location.href = '<?= $requestUri ?>';
        }

        function clearTxt() {
            document.getElementById('txt');
            txt.innerHTML = "";
        }
    </script>

</head>

<body bgcolor="#CCCCCC">
<div style="width:1000px;height:auto;background:#CCCCCC;margin:0 auto;">
    <br/><br/>
    <h2 align="center" style="font-size:26px;font-weight:bold;"><?= $sysName ?></h2>
    <br/><br/>
    <hr/>
    <br/>
    <div>
        <BUTTON class="btn" type="button" onclick="history.go(-1)">返回</BUTTON>&nbsp;&nbsp;
        <?php if(array_key_exists('type', $_GET)&&$_GET['type']=='file')echo rtrim($dirPath,'/').'/',$_GET['filename'];else echo $dirPath; ?>
    </div>
    <br/>
    <?php if($action == 'update'){?>
    <div class="updata" style="width: 998px;">
        <form action="<?= $requestUri ?>" method="post" name="myform">
            <textarea id="txt" style="padding: 10px;" name="filecontent"><?php echo $fileContent; ?></textarea>
            <input type="hidden" value="<?php echo $_GET['filename']; ?>" name="filename"/>

            <div style="margin-top: 20px">
                <input class="btn" style="float:right;margin-left:20px;" onclick="clearTxt()" type="button" value="清空"/>
                <input class="btn" style="float:right;" type="submit" value="保存"/>
            </div>

        </form>
    </div>
    <br/><br/>
    <?php }elseif($action == 'look'){ ?>
    <pre style="font-size: 16px;background: white;padding: 15px"><?php echo $fileContent ?></pre>
    <?php }else{ ?>
    <?php if(in_array('create',$fileAction)){ ?>
    <!--创建文件-->
    <div class="createFile" style="text-align: right;padding-right: 0;">
        <form action="<?= $requestUri ?>" method="post" name="myform2">
            <input type="hidden" name="action" value="create"/>
            <input style="width:200px;height:30px;padding: 5px;border: 1px solid #bbb" type="text" name="filename"/>
            <input class="btn" type="submit" value="创建"/>
        </form>
    </div>
    <?php } ?>
    <div class="fileMes" style="width:1000px;">
        <table style="width:100%;height:auto;">
            <tr style="background:#abcdef;">
                <th>序号</th>
                <th>文件名</th>
                <th>文件类型</th>
                <th>文件大小</th>
                <th>创建日期</th>
                <th colspan="2">操作</th>
            </tr>
            <?php
				foreach ($fileMes as $k=>$v){
            ?>
            <tr>
                <td><?php echo ($k+1);?></td>
                <td align="left" style="padding-left: 30px"><?php echo $v['fileName'];?></td>
                <td><?php echo $v['fileType'];?></td>
                <td><?php echo $v['fileSize'];?></td>
                <td><?php echo date("Y-m-d",$v['filemtime']);?></td>
                <td>
                <?php if($v['fileType']=='dir'){?>
                    <a href="<?= $requestUri ?>action=open&dir=<?php echo urlencode($dirPath).'/'.$v['fileName'];?>&type=<?php echo $v['fileType'];?>&filename=<?php echo $v['fileName'];?>">打开</a>
                <?php }else{?>
                    <a href="<?= $requestUri ?>action=look&dir=<?php echo urlencode($dirPath);?>&type=<?php echo $v['fileType'];?>&filename=<?php echo $v['fileName'];?>">查看</a>
                    <?php if(in_array('update',$fileAction)){ ?>
                    <a href="<?= $requestUri ?>action=update&dir=<?php echo urlencode($dirPath);?>&type=<?php echo $v['fileType'];?>&filename=<?php echo $v['fileName'];?>">编辑</a>
                    <?php } ?>
                <?php } ?>
                    <?php if(in_array('delete',$fileAction)){ ?>
                    <a href="<?= $requestUri ?>action=delete&filename=<?php echo $v['fileName']; ?>">删除</a>
                    <?php } ?>
                </td>
            </tr>
            <?php } ?>
        </table>
    </div>
    <?php } ?>
</div>
<br><br><br>
</body>

</html>